Skip to content

fix(router): allow numeric parameters in generatePath types - #15345

Open
SANJAY2334 wants to merge 1 commit into
remix-run:mainfrom
SANJAY2334:fix/generatepath-numeric-params
Open

fix(router): allow numeric parameters in generatePath types#15345
SANJAY2334 wants to merge 1 commit into
remix-run:mainfrom
SANJAY2334:fix/generatepath-numeric-params

Conversation

@SANJAY2334

@SANJAY2334 SANJAY2334 commented Jul 25, 2026

Copy link
Copy Markdown

Problem

The runtime implementation of generatePath already accepts numeric parameter values by converting them with String(...). However, the TypeScript definitions only allow string values, forcing developers to write unnecessary casts such as String(userId).

This creates a mismatch between the runtime behavior and the compile-time API.

Root Cause

GeneratePathParams and ParseParams restrict parameter values to string (or string | null | undefined for optional parameters), even though the runtime implementation already handles numeric values.

Solution

This PR updates the TypeScript definitions to allow:

  • string | number
  • string | number | null | undefined for optional parameters

This aligns the type definitions with the existing runtime behavior without changing runtime logic.

Tests

Added compile-time and runtime tests covering:

  • Required numeric parameters
  • Multiple numeric parameters
  • Optional numeric parameters
  • Mixed string/number parameters
  • Existing string behavior

Backward Compatibility

This change is fully backward compatible. Existing code using string parameters continues to compile unchanged because string remains assignable to the updated types.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ CLA Signature Required

Hi @SANJAY2334, thanks for contributing to React Router!

Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.

You may review the CLA and sign it by adding your GitHub username to contributors.yml.

Once the CLA is signed, the CLA Signed label will be added to the pull request and the CI check will pass.

Thanks!

- The Remix team

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ No Change File Found

This PR doesn't include a change file which is used for automated release notes.
If your change affects users, please add one (or more) change files and commit the generated file(s).

pnpm run changes:add

This script requires Node 24+. If you are on a lower version, please add a file manually

Not every PR needs a change file — you can skip this step if the change is internal-only
(tests, tooling, docs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant